package com.flatsmap.dao;

import java.util.List;

import org.springframework.orm.hibernate3.support.HibernateDaoSupport;


public abstract class AbstractDao<T> extends HibernateDaoSupport {

	public void save(T object){
		getHibernateTemplate().merge(object);
	}
	
	public List<T> getAll() {
		return getSession().createCriteria(getClazz())
		.list();
	}
	
	public T getSingl() {
		return (T)getSession().createCriteria(getClazz())
		.setMaxResults(1).uniqueResult();
	}
	
	public void delete(T object){
		getHibernateTemplate().delete(object);
	}
	
	public abstract Class getClazz(); 
}

